package com.applcn.shop.repo.repository;

import com.applcn.shop.repo.entity.CategoryEntity;
import com.applcn.shop.repo.mapper.CategoryMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * com.applcn.shop.repo.repository
 * Description:
 *
 * @author: 大妖怪
 * @date: 2020-01-19 20:57
 */
@Repository
public class CategoryRepository extends ServiceImpl<CategoryMapper, CategoryEntity> {

    /**
     * 查询类目列表
     *
     * @param parentId
     * @return
     */
    public List<CategoryEntity> getCategoryList(Long parentId) {
        return baseMapper.selectList(
                new QueryWrapper<CategoryEntity>()
                .lambda()
                .eq(CategoryEntity::getParentId, parentId)
                .orderByAsc(CategoryEntity::getSort)
        );
    }
}
